package com.utils;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.google.gson.JsonObject;

public class SearchQQ {
	final static String qqServerUrl = "https://api.bzqll.com/music/tencent/search";
	private static String name;
	private static String singer;
	private static String url;
	private static String pic;
	private static String id;
	
	public static void search(String s) throws Exception{
		// 添加参数
		Map<String, String> params = new HashMap<String, String>();
		params.put("s", s);
		params.put("key", "579621905");
		params.put("limit", "1");
		params.put("offset", "0");
		params.put("type", "song");

		// 调用 get 请求
		String res = HttpUtils.get(qqServerUrl, params, null);
		res = res.substring(res.indexOf("{"));// 截取
		com.alibaba.fastjson.JSONObject result = JSON.parseObject(res);// 转JSON
		String resultToString = result.toString();
		JsonObject subObject = ReadJSON.parseJSON(resultToString);

		name = subObject.get("name").getAsString();
		singer = subObject.get("singer").getAsString();
		url = subObject.get("url").getAsString();
		pic = subObject.get("pic").getAsString();
		id = subObject.get("id").getAsString();
	}
	public static String getName() {
		return name;
	}
	public static void setName(String name) {
		SearchQQ.name = name;
	}
	public static String getSinger() {
		return singer;
	}
	public static void setSinger(String singer) {
		SearchQQ.singer = singer;
	}
	public static String getUrl() {
		return url;
	}
	public static void setUrl(String url) {
		SearchQQ.url = url;
	}
	public static String getPic() {
		return pic;
	}
	public static void setPic(String pic) {
		SearchQQ.pic = pic;
	}
	public static String getId() {
		return id;
	}
	public static void setId(String id) {
		SearchQQ.id = id;
	}
	public static String getQqserverurl() {
		return qqServerUrl;
	}
	
	
	
	

}
